package com.shunda.common.constant;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 角色常量信息
 *
 * @author shunda
 */
public enum RoleConstants {
    /**
     * 超级管理员
     */
    ADMIN(1L, "admin"),
    /**
     * 管理员
     */
    MANAGE(2L, "manage"),
    /**
     * 站长
     */
    MASTER(3L, "master"),
    /**
     * 班长
     */
    MONITOR(4L, "monitor"),
    /**
     * 加油员
     */
    SALESMAN(5L, "salesman");

    private Long roleId;

    private String roleName;

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    private RoleConstants(Long roleId, String roleName) {
        this.roleId = roleId;
        this.roleName = roleName;
    }

    /**
     * 获取不可变的角色ID集合
     * @return List<Long>
     */
    public static List<Long> getImmobilizationRoleIds() {
        return Arrays.stream(values()).map(RoleConstants::getRoleId).collect(Collectors.toList());
    }

    public static boolean isAdmin(Long roleId) {
        return roleId != null && roleId == 1L;
    }

    public static boolean isAdmin(List<Long> roleIds) {
        if (roleIds.contains(1L)) {
            return isAdmin(1L);
        }
        return false;
    }

    public static boolean isManage(Long roleId) {
        return roleId != null && roleId == 2L;
    }

    public static boolean isManage(List<Long> roleIds) {
        if (roleIds.contains(2L)) {
            return isManage(2L);
        }
        return false;
    }

    public static boolean isMaster(Long roleId) {
        return roleId != null && roleId == 3L;
    }

    public static boolean isMaster(List<Long> roleIds) {
        if (roleIds.contains(3L)) {
            return isMaster(3L);
        }
        return false;
    }

    public static boolean isMonitor(Long roleId) {
        return roleId != null && roleId == 4L;
    }

    public static boolean isMonitor(List<Long> roleIds) {
        if (roleIds.contains(4L)) {
            return isMonitor(4L);
        }
        return false;
    }

    public static boolean isSalesman(Long roleId) {
        return roleId != null && roleId == 5L;
    }

    public static boolean isSalesman(List<Long> roleIds) {
        if (roleIds.contains(5L)) {
            return isSalesman(5L);
        }
        return false;
    }
}
